FROM rust AS base
ENV RUSTUP_DIST_SERVER="https://rsproxy.cn"
ENV RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
# sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources && \
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources && \
  apt update -y && apt install cmake -y && cargo install xiu

FROM scratch AS deploy
# FROM gcr.linkos.org/distroless/base AS runner
# COPY --from=base /usr/local/cargo/bin/xiu xiu
# ARG CONFIG_FILE
# ENV CONFIG_FILE=${CONFIG_FILE}
COPY --from=base /usr/local/cargo/bin/xiu xiu
COPY --from=base /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/x86_64-linux-gnu/libgcc_s.so.1
COPY --from=base /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/libm.so.6
COPY --from=base /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
COPY --from=base /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
COPY config.toml config/config.toml
CMD ["./xiu", "-c", "config/config.toml"]

EXPOSE 1935
EXPOSE 8000
